package org.scs.carleton.ca.pgdt.core.ui.internal.highlighting;

import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.Token;

/**
 * The scanner is responsible for finding comments within a prolog document.  This labels it with a "PROLOG_COMENT" token.  later on,
 * the presenter will visit these tokens and colour anything associated with the PROLOG_COMMENT token a specific colour.
 * 
 * @author tessierj
 */
public class PrologPartitionScanner extends RuleBasedPartitionScanner {
	private static final String END_SEQUENCE = "*/"; //$NON-NLS-1$
	private static final String START_SEQUENCE = "/*"; //$NON-NLS-1$
	private static final String START_COMMENT = "%"; //$NON-NLS-1$
	public final static String PROLOG_COMMENT = "__prolog_comment"; //$NON-NLS-1$

	public PrologPartitionScanner() {
		IToken prologComment = new Token(PROLOG_COMMENT);

		IPredicateRule[] rules = new IPredicateRule[2];

		rules[0] = new EndOfLineRule(START_COMMENT, prologComment);
		rules[1] = new MultiLineRule(START_SEQUENCE, END_SEQUENCE, prologComment);
		setPredicateRules(rules);
	}
}
